package com.session01.pm.game;

public class Hero {
    String name;
    int hp;
    int attack;
    int defence;

    public void fight(Monster m) {
        System.out.println(this.name + "使用技能，攻击" + m.name);
        m.injured(this);
    }

    public void injured(Monster m) {
        int lostLife = m.attack - this.defence;
/*        if (lostLife <= 1) {
            lostLife = 1;
        }*/
        this.hp -= lostLife;
        System.out.println(this.name + "受到" + lostLife + "点伤害,剩余血量:" + this.hp);
    }
}
